Skip to content

[CI] (0c6666c) javascript-node/fastify-blog - #1202

Closed
wizard-ci-bot[bot] wants to merge 1 commit into
mainfrom
wizard-ci-0c6666c-javascript-node-fastify-blog
Closed

wizard-ci-bot[bot] wants to merge 1 commit into
mainfrom
wizard-ci-0c6666c-javascript-node-fastify-blog

Conversation

@wizard-ci-bot

@wizard-ci-bot wizard-ci-bot Bot commented Apr 15, 2026

Copy link
Copy Markdown

Automated wizard CI run

Source: wizard-pr
Trigger ID: 0c6666c
App: javascript-node/fastify-blog
App directory: apps/javascript-node/fastify-blog
Workbench branch: wizard-ci-0c6666c-javascript-node-fastify-blog
Wizard branch: release-please--branches--main--components--wizard
Context Mill branch: main
PostHog (MCP) branch: master
Timestamp: 2026-04-15T18:05:57.221Z
Duration: 291.4s

@wizard-ci-bot

wizard-ci-bot Bot commented Apr 15, 2026

Copy link
Copy Markdown
Author

Now I have all the information needed. Let me note the key findings:

  1. captureException exists on posthog-node but requires a distinctId as the second parameter — the PR calls posthog.captureException(err) without a distinctId, which means exceptions won't be linked to any user.
  2. enableExceptionAutocapture is a valid config option.
  3. No .env.example file exists — the .env file has the keys but is not committed (not in the changed files list). There's no .env.example to document required env vars.
  4. distinctId uses author — the author field from request body is used as distinct_id, which is a user-provided string (like a name/username). This is acceptable for a blog API where author is the user identifier.
  5. This is a server-only Fastify/Node.js app — ph_identify and ph_reverse_proxy are N/A.

PR Evaluation Report

Summary

This PR integrates PostHog analytics into a Fastify blog API using the posthog-node server SDK. It adds event tracking for all write operations (post CRUD and comment creation), sets up error handling via Fastify's error handler, enables exception autocapture, and ensures graceful shutdown with posthog.shutdown().

Files changed Lines added Lines removed
3 +106 -2

Confidence score: 4/5 👍

  • captureException missing distinctId: The error handler calls posthog.captureException(err) without passing a distinctId. The posthog-node SDK signature is captureException(error, distinctId?, additionalProperties?). Without a distinctId, the exception event will lack user association. Should extract a user identifier from the request context if available. [MEDIUM]
  • No .env.example file: Environment variables POSTHOG_API_KEY and POSTHOG_HOST are required but no .env.example is committed to document them. A .env file exists locally but is not part of the PR. [MEDIUM]

File changes

Filename Score Description
apps/javascript-node/fastify-blog/index.js 4/5 Added PostHog initialization, capture calls on all write routes, error handler with captureException, and graceful shutdown handlers
apps/javascript-node/fastify-blog/package.json 5/5 Added posthog-node dependency
apps/javascript-node/fastify-blog/posthog-setup-report.md 4/5 Setup report documenting events and suggested dashboards

App sanity check ⚠️

Criteria Result Description
App builds and runs Yes Valid ESM imports, correct package dependency added, no syntax issues
Preserves existing env vars & configs Yes Existing code preserved; only PostHog additions and a minor refactor in delete route to capture post data before splicing
No syntax or type errors Yes All code is syntactically valid JavaScript
Correct imports/exports Yes PostHog correctly imported from posthog-node
Minimal, focused changes Yes All changes relate to PostHog integration
Pre-existing issues None Base app functions correctly

Issues

  • No .env.example documented: The PR does not include a .env.example file to document the required POSTHOG_API_KEY and POSTHOG_HOST environment variables. New developers cloning the repo won't know which env vars are needed. [MEDIUM]

Other completed criteria

  • App builds without errors — valid syntax, correct dependency added
  • Existing functionality preserved — all original routes and logic intact
  • Changes are minimal and focused on PostHog integration
  • Import statement correctly uses named import from posthog-node
  • Build configuration valid — package.json is properly formatted with new dependency

PostHog implementation ⚠️

Criteria Result Description
PostHog SDKs installed Yes posthog-node ^5.29.2 added to package.json dependencies
PostHog client initialized Yes new PostHog(process.env.POSTHOG_API_KEY, { host, enableExceptionAutocapture }) at module level
capture() Yes 5 meaningful capture calls across all write endpoints
identify() N/A Server-only app — not applicable
Error tracking Yes captureException in error handler + enableExceptionAutocapture config, though distinctId is missing from the captureException call
Reverse proxy N/A Server-only app — not applicable

Issues

  • captureException called without distinctId: In the Fastify error handler (setErrorHandler), posthog.captureException(err) is called without a distinctId. The posthog-node signature is captureException(error, distinctId?, additionalProperties?). While the enableExceptionAutocapture config handles uncaught exceptions globally, the manual captureException call should ideally include a user identifier from the request context (e.g., request.body?.author) so exceptions are linked to the user who triggered them. [MEDIUM]

Other completed criteria

  • API key loaded from process.env.POSTHOG_API_KEY — not hardcoded
  • Host loaded from process.env.POSTHOG_HOST — correctly configured
  • posthog.shutdown() called on SIGINT and SIGTERM for graceful flush
  • enableExceptionAutocapture: true enabled for automatic uncaught exception tracking

PostHog insights and events ✅

Filename PostHog events Description
index.js post created Tracks new blog post creation with post_id and title
index.js post updated Tracks post edits with post_id, title, and published status
index.js post published Dedicated event when published flag set to true — enables creation→publish funnel
index.js post deleted Tracks post deletion with post_id and title
index.js comment added Tracks comment creation with comment_id, post_id, and post_title
index.js captureException Forwards unhandled Fastify errors to PostHog error tracking

Issues

No critical or medium issues with event quality.

Other completed criteria

  • Events represent real user actions (create, update, publish, delete, comment)
  • Events enable product insights — can build creation→publication funnel, content velocity trends, engagement metrics
  • Events include relevant contextual properties (post_id, title, published status, comment_id)
  • No PII in event properties — author is used as distinctId (person identifier), not in event properties
  • Event names are descriptive and use consistent noun verb convention in lowercase

Reviewed by wizard workbench PR evaluator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants